package com.itheima.mapper;

import com.itheima.pojo.Order;
import com.itheima.pojo.OrderDTO;
import com.itheima.pojo.OrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface OrderMapper {
    /**
     * 查询预约信息
     * @param id
     * @return
     */
    @Select("select a.name as member,b.orderDate,b.orderType,c.name as setmeal " +
            "from t_member a,t_order b,t_setmeal c where a.id=b.member_id and b.setmeal_id=c.id and b.id=#{id}")
    OrderVO list(Integer id);

    /**
     * 同一个用户同一天预约了同一个套餐
     * @param orderDTO
     * @return
     */
    @Select("select b.id, member_id, orderDate, orderType, orderStatus, setmeal_id from " +
            "t_member a,t_order b where a.id=b.member_id and a.name=#{name} and b.setmeal_id=#{setmealId} and b.orderDate like concat('%',#{orderDate},'%')")
    Order listed(OrderDTO orderDTO);

    /**
     * 插入数据
     * @param order1
     */
    void insert(Order order1);
}
